package com.jdzy.student.controller;

import com.jdzy.model.common.vos.Result;
import com.jdzy.model.student.dtos.CopyrightDeleteDto;
import com.jdzy.model.student.dtos.CopyrightDto;
import com.jdzy.model.student.dtos.CopyrightRearchDto;
import com.jdzy.student.service.CopyrightService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@CrossOrigin
@Slf4j
@RequestMapping("api/copyright")
@Api(value = "Copyright的controller类")
public class CopyrightController {
    @Autowired
    private CopyrightService copyrightService;

    /**
     * 根据学号获取其著作权
     * @param stuId
     * @return
     */
    @PostMapping("/getCopyrightByStuId/{stuId}/{page}/{size}")
    public Result getCopyrightByStuId(@PathVariable String stuId, @PathVariable Integer page
            , @PathVariable Integer size, @RequestBody CopyrightRearchDto copyrightRearchDto){
        log.info("根据学号获取其著作权,参数:{},{},{},{}",stuId,page,size,copyrightRearchDto);
        return copyrightService.getCopyrightByStuId(stuId,page,size,copyrightRearchDto);
    }

    /**
     * 删除著作权信息
     * @param stuId
     * @param copyrightDeleteDto
     * @return
     */
    @DeleteMapping("deleteCopyright/{stuId}")
    public Result deleteCopyright(@PathVariable String stuId, @RequestBody CopyrightDeleteDto copyrightDeleteDto){
        log.info("删除著作权信息,参数:{},{}",stuId,copyrightDeleteDto);
        return copyrightService.deleteCopyright(stuId,copyrightDeleteDto);
    }

    /**
     * 保存Copyright信息
     * @param copyrightDto
     * @return
     */
    @PostMapping("saveCopyright")
    public Result saveCopyright(@RequestBody CopyrightDto copyrightDto){
        log.info("保存Copyright信息,参数:{}",copyrightDto);
        return copyrightService.saveCopyright(copyrightDto);
    }

    /**
     * 修改Copyright信息
     * @param copyrightDto
     * @return
     */
    @PostMapping("updateCopyright")
    public Result updateCopyright(@RequestBody CopyrightDto copyrightDto){
        log.info("修改Copyright信息,参数:{}",copyrightDto);
        return copyrightService.updateCopyright(copyrightDto);
    }
}
